﻿using AfvandingService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AfvandingKlient
{
    public partial class PumpeGUI : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["OpdatérEllerOpret"].ToString() == "Opdatér")
            {
                _pageHeader.Text = "Opdatér Pumpe";
            }
        }

        protected void btnOpretPumpe_Click(object sender, EventArgs e)
        {
            ChannelFactory<ICentral> proxy = (ChannelFactory<ICentral>)Session["proxy"];
            ICentral central = proxy.CreateChannel();

            if (Session["OpdatérEllerOpret"].ToString() == "Opret")
            {
                central.AnmodOpretPumpe(int.Parse(Session["PumpestationsNr"].ToString()), double.Parse(txtboxKapacitet.Text), int.Parse(txtboxPumpenr.Text));
                Response.Redirect("CentralSystem.aspx");
            }

            else if (Session["OpdatérEllerOpret"].ToString() == "Opdatér")
            {
                central.AnmodOpdatérPumpe(int.Parse(Session["PumpestationsNr"].ToString()), double.Parse(txtboxKapacitet.Text), int.Parse(txtboxPumpenr.Text));
                Response.Redirect("CentralSystem.aspx");
            }
        }

        protected void btnCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("CentralSystem.aspx");
        }
    }
}